﻿-- Define the relationship between BusinessRoleAccess and SecurityRole
ALTER TABLE [dbo].[BusinessRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_BusinessRoleAccess_BusinessRole] FOREIGN KEY([BusinessRole])
REFERENCES [dbo].[BusinessRole] ([RoleId])
ON DELETE NO ACTION
GO
-- Define the relationship between BusinessRoleAccess and SecurityRole
ALTER TABLE [dbo].[BusinessRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_BusinessRoleAccess_SecurityRole] FOREIGN KEY([SecurityRole])
REFERENCES [dbo].[SecurityRole] ([RoleId])
ON DELETE NO ACTION
GO
-- Define the relationship between BusinessRoleAccess and Person
ALTER TABLE [dbo].[BusinessRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_BusinessRoleAccess_CreatedByPerson] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between BusinessRoleAccess and Person
ALTER TABLE [dbo].[BusinessRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_BusinessRoleAccess_LastChangedBy] FOREIGN KEY([LastChangedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between BusinessRoleAccess and Person
ALTER TABLE [dbo].[BusinessRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_BusinessRoleAccess_Person] FOREIGN KEY([Person])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO